//
//  OrderDetailViewController.m
//  JiuJiuShangCheng
//
//  Created by jiujiukeji on 2018/7/13.
//  Copyright © 2018年 jiujiukeji. All rights reserved.
//

#import "OrderDetailViewController.h"
#import "ShouHuoAddressTableViewCell.h"
#import "OrderTableViewCell.h"
#import "ShouHouViewController.h"
#import "PingJiaViewController.h"
#import "OrderPingJiaTableViewCell.h"
#import "ZhiFuViewController.h"
#import "WuLiuInfoViewController.h"
#import "TuiKuanDetailViewController.h"
#import "PingJiaDetailViewController.h"

@interface OrderDetailViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSDictionary *orderDic;

@end

@implementation OrderDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = tableViewBgColor;
    [self loadBaseTitleLable:@"订单详情"];
    
    [self.view addSubview:self.tableView];
    [self getOrderDetail];
}
- (void)getOrderDetail
{
    if (self.ordersNumber) {
        NSString *code = [NSString stringWithFormat:@"%@%@",safeCode,[GetTimestamp getNowTimeTimestamp]];
        [MBProgressHUD showMessage:nil toView:self.view];
        [TFNetworking getWithURLString:[NSString stringWithFormat:@"%@/api/json/member/order.ashx?action=ordercontent&companyid=%@&code=%@&timestamp=%@&ordersNumber=%@&from=mobile",kServerURL,companyId,[MD5Encrypt  MD5ForLower32Bate:code],[GetTimestamp getNowTimeTimestamp],self.ordersNumber] parameters:nil success:^(id responseObject) {
            [MBProgressHUD hideHUDForView:self.view];
            self.orderDic = [NSDictionary dictionary];
            if ([responseObject[@"status"] intValue] == 1) {
                self.orderDic = responseObject;
            }
            [self.tableView reloadData];
            
        } failure:^(NSError *error) {
            [TFHUD addRemindHUD:self.view message:@"网络不给力..."];
        }];
    }
}
#pragma mark - tableView delegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 4;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 2) {
        return 4;
    } else if (section == 3) {
        return 3;
    } else if (section == 1) {
        if (self.orderDic) {
            NSArray *array = self.orderDic[@"OrderGoodsList"];
            return array.count;
        } else {
            return 0;
        }
        
    } else {
        return 1;
    }
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        ShouHuoAddressTableViewCell *cell = [[ShouHuoAddressTableViewCell alloc] init];
        // 赋值
        if (self.orderDic) {
            cell.contactInfoLB.text = [NSString stringWithFormat:@"收货人：%@     %@",self.orderDic[@"ReceiptName"],self.orderDic[@"ReceiptPhone"]];
            cell.addressLB.text = [NSString stringWithFormat:@"地址：%@",self.orderDic[@"ReceiptAddress"]];
        }
        cell.selectionStyle = NO;
        return cell;
    } else if (indexPath.section == 1) {
        if ([self.orderDic[@"orderStatus"] intValue] == 4) {
            // 已经签收
            OrderPingJiaTableViewCell *cell = [[OrderPingJiaTableViewCell alloc] init];
            cell.shouHouBtn.tag = indexPath.row;
            cell.pingJiaBtn.tag = indexPath.row;
            [cell.shouHouBtn addTarget:self action:@selector(shouHouAction:) forControlEvents:(UIControlEventTouchUpInside)];
            [cell.pingJiaBtn addTarget:self action:@selector(pingJiaAction:) forControlEvents:(UIControlEventTouchUpInside)];
            // 赋值
            if (self.orderDic) {
                NSArray *array = _orderDic[@"OrderGoodsList"];
                NSDictionary *dic = array[indexPath.row];
                [cell.goodsImg sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http:%@",dic[@"CartImg"]]]];
                cell.goodsTitleLB.text = dic[@"CommodityName"];
                cell.priceLB.text = [NSString stringWithFormat:@"￥%.2f",[dic[@"CommodityXPrice"] floatValue]];
                cell.describeLB.text = dic[@"CommodityProperty"];
                cell.numLB.text = [NSString stringWithFormat:@"×%@",dic[@"CommodityNumber"]];
            }
            cell.selectionStyle = NO;
            return cell;
        } else {
            OrderTableViewCell *cell = [[OrderTableViewCell alloc] init];
            // 赋值
            if (self.orderDic) {
                NSArray *array = _orderDic[@"OrderGoodsList"];
                NSDictionary *dic = array[indexPath.row];
                [cell.goodsImg sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http:%@",dic[@"CartImg"]]]];
                cell.goodsTitleLB.text = dic[@"CommodityName"];
                cell.priceLB.text = [NSString stringWithFormat:@"￥%.2f",[dic[@"CommodityXPrice"] floatValue]];
                cell.describeLB.text = dic[@"CommodityProperty"];
                cell.numLB.text = [NSString stringWithFormat:@"×%@",dic[@"CommodityNumber"]];
            }
            cell.selectionStyle = NO;
            return cell;
        }
        
    } else if (indexPath.section == 2) {
        UITableViewCell *cell = [[UITableViewCell alloc] init];
        cell.textLabel.textColor = UIColorFromRGB(0x909090);
        cell.textLabel.font = UIFontSystem(13);
        [cell.textLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(cell.contentView).offset(rateWidth(28));
            make.centerY.equalTo(cell.contentView);
        }];
        
        NSArray *array = @[[NSString stringWithFormat:@"订单编号：%@",self.orderDic[@"ordersNumber"]],[NSString stringWithFormat:@"下单时间：%@",self.orderDic[@"orderDate"]],[NSString stringWithFormat:@"支付方式：%@",self.orderDic[@"ordersZffs"]],[NSString stringWithFormat:@"送货方式：%@",self.orderDic[@"orderDeliveryType"]]];
        cell.textLabel.text = array[indexPath.row];
        cell.selectionStyle = NO;
        return cell;
    } else {
        UITableViewCell *cell = [[UITableViewCell alloc] init];
        UILabel *leftLB = [UILabel labelWithText:@"" textColor:UIColorFromRGB(0x909090) fontSize:13];
        [leftLB sizeToFit];
        [cell.contentView addSubview:leftLB];
        [leftLB mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(cell.contentView).offset(rateWidth(28));
            make.centerY.equalTo(cell.contentView);
        }];
        UILabel *rightLB = [UILabel labelWithText:@"" textColor:UIColorFromRGB(0x909090) fontSize:13];
        [rightLB sizeToFit];
        [cell.contentView addSubview:rightLB];
        [rightLB mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(cell.contentView).offset(-rateWidth(28));
            make.centerY.equalTo(cell.contentView);
        }];
        NSArray *array1 = @[@"商品总额",@"运费",@"实付款"];
        leftLB.text = array1[indexPath.row];
        if (self.orderDic) {
            NSArray *array2 = @[[NSString stringWithFormat:@"￥%.2f",[self.orderDic[@"orderTotalprice"] floatValue]],[NSString stringWithFormat:@"￥%.2f",[self.orderDic[@"orderFreight"] floatValue]],[NSString stringWithFormat:@"￥%.2f",[self.orderDic[@"orderTotalprice"] floatValue]+[self.orderDic[@"orderFreight"] floatValue]]];
            rightLB.text = array2[indexPath.row];
        }
        if (indexPath.row == 2) {
            rightLB.textColor = navBarColor;
        }
        
        cell.selectionStyle = NO;
        return cell;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return rateHeight(130);
    } else if (indexPath.section == 1) {
        if ([self.orderDic[@"orderStatus"] intValue] == 4) {
            return rateHeight(310);
        } else {
            return rateHeight(180);
        }
        
    } else if (indexPath.section == 2) {
        return rateHeight(50);
    } else {
        return rateHeight(50);
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 1) {
        return rateHeight(100);
    } else if (section == 2 || section == 3) {
        return rateHeight(10);
    } else {
        return 0.01;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    if (section == 0) {
        return rateHeight(10);
    } else if (section == 1) {
        if ([self.orderDic[@"orderStatus"] intValue] == 2 || [self.orderDic[@"orderStatus"] intValue] == 4) {
            return rateHeight(90);
        } else {
            return rateHeight(200);
        }
    } else {
        return 0.01;
    }
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *bgV = [[UIView alloc] init];
    if (section == 1) {
        bgV.backgroundColor = UIColorWhite;
        UIImageView *shopImg = [[UIImageView alloc] init];
        shopImg.image = UIImageNamed(@"shopImg");
        [shopImg sizeToFit];
        [bgV addSubview:shopImg];
        [shopImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(bgV).offset(rateWidth(30));
            make.centerY.equalTo(bgV);
        }];
        
        UILabel *label = [UILabel labelWithText:AppName textColor:UIColorFromRGB(0x3b3b3b) fontSize:13];
        [label sizeToFit];
        [bgV addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(bgV);
            make.left.equalTo(shopImg.mas_right).offset(rateWidth(20));
        }];
        UILabel *label1 = [UILabel labelWithText:self.orderDic[@"ordersType"] textColor:UIColorFromRGB(0xf55555) fontSize:13];
        [label1 sizeToFit];
        [bgV addSubview:label1];
        [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(bgV);
            make.right.equalTo(bgV).offset(-rateWidth(30));
        }];
        
    }
    return bgV;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    if (section == 1) {
        if ([self.orderDic[@"orderStatus"] intValue] == 2 || [self.orderDic[@"orderStatus"] intValue] == 4) {
            UIView *bgV = [[UIView alloc] init];
            bgV.backgroundColor = tableViewBgColor;
            UIView *whiteV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, rateHeight(90))];
            whiteV.backgroundColor = UIColorWhite;
            [bgV addSubview:whiteV];
            UILabel *priceLB = [UILabel labelWithText:@"￥0.00" textColor:UIColorFromRGB(0xf55555) fontSize:13];
            [priceLB sizeToFit];
            [whiteV addSubview:priceLB];
            [priceLB mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(whiteV).offset(-rateWidth(30));
                make.top.equalTo(whiteV).offset(rateHeight(25));
            }];
            UILabel *heJiLB = [UILabel labelWithText:@"合计：" textColor:UIColorFromRGB(0x909090) fontSize:13];
            [heJiLB sizeToFit];
            [whiteV addSubview:heJiLB];
            [heJiLB mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.equalTo(priceLB);
                make.right.equalTo(priceLB.mas_left);
            }];
            priceLB.text = [NSString stringWithFormat:@"￥%.2f",[self.orderDic[@"orderTotalprice"] floatValue]];
            return bgV;
        } else {
            UIView *bgV = [[UIView alloc] init];
            bgV.backgroundColor = tableViewBgColor;
            UIView *whiteV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, rateHeight(200))];
            whiteV.backgroundColor = UIColorWhite;
            [bgV addSubview:whiteV];
            UILabel *priceLB = [UILabel labelWithText:@"￥0.00" textColor:UIColorFromRGB(0xf55555) fontSize:13];
            [priceLB sizeToFit];
            [whiteV addSubview:priceLB];
            [priceLB mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(whiteV).offset(-rateWidth(30));
                make.top.equalTo(whiteV).offset(rateHeight(25));
            }];
            UILabel *heJiLB = [UILabel labelWithText:@"合计：" textColor:UIColorFromRGB(0x909090) fontSize:13];
            [heJiLB sizeToFit];
            [whiteV addSubview:heJiLB];
            [heJiLB mas_makeConstraints:^(MASConstraintMaker *make) {
                make.centerY.equalTo(priceLB);
                make.right.equalTo(priceLB.mas_left);
            }];
            UIButton *btn1 = [UIButton buttonWithTitle:@"" fontSize:15 titleColor:UIColorWhite background:navBarColor cornerRadius:3];
            [whiteV addSubview:btn1];
            [btn1 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(whiteV).offset(-rateWidth(30));
                make.size.mas_offset(CGSizeMake(rateWidth(180), rateHeight(70)));
                make.bottom.equalTo(whiteV).offset(-rateHeight(30));
            }];
            
            UIButton *btn2 = [UIButton buttonWithTitle:@"" fontSize:15 titleColor:UIColorFromRGB(0x3b3b3b) background:UIColorFromRGB(0xf5f5f5) cornerRadius:3];
            [whiteV addSubview:btn2];
            [btn2 mas_makeConstraints:^(MASConstraintMaker *make) {
                make.right.equalTo(btn1.mas_left).offset(-rateWidth(40));
                make.size.mas_offset(CGSizeMake(rateWidth(180), rateHeight(70)));
                make.centerY.equalTo(btn1);
            }];
            
            // 赋值
            priceLB.text = [NSString stringWithFormat:@"%.2f",[self.orderDic[@"orderTotalprice"] floatValue]];
            if ([self.orderDic[@"orderStatus"] intValue] == 1) {
                // 待付款
                [btn1 setTitle:@"支付" forState:(UIControlStateNormal)];
                [btn2 setTitle:@"取消订单" forState:(UIControlStateNormal)];
                
                btn2.tag = section;
                [btn2 addTarget:self action:@selector(quXiaoOrder:) forControlEvents:(UIControlEventTouchUpInside)];
                [btn1 addTarget:self action:@selector(zhiFuOrder) forControlEvents:(UIControlEventTouchUpInside)];
                
            } else if ([self.orderDic[@"orderStatus"] intValue] == 3) {
                // 待收货
                [btn1 setTitle:@"确认收货" forState:(UIControlStateNormal)];
                [btn2 setTitle:@"查看物流" forState:(UIControlStateNormal)];
                
                btn1.tag = section;
                [btn1 addTarget:self action:@selector(queRenShouHuo) forControlEvents:(UIControlEventTouchUpInside)];
                
                btn2.tag = section;
                [btn2 addTarget:self action:@selector(chaKanWuLiu:) forControlEvents:(UIControlEventTouchUpInside)];
                
            }
            return bgV;
        }
    } else {
        return nil;
    }
}
#pragma mark - 查看物流
- (void)chaKanWuLiu:(UIButton *)btn
{
    if (self.orderDic[@"orderDeliveryInfo"]) {
        WuLiuInfoViewController *wuLiuInfoVC = [[WuLiuInfoViewController alloc] init];
        wuLiuInfoVC.ordersnumber = self.ordersNumber;
        wuLiuInfoVC.wuLiuInfo = self.orderDic[@"orderDeliveryInfo"];
        [self.navigationController pushViewController:wuLiuInfoVC animated:YES];
    }
}
#pragma mark - 支付
- (void)zhiFuOrder
{
    if (self.orderDic) {
        ZhiFuViewController *zhiFuVC = [[ZhiFuViewController alloc] init];
        zhiFuVC.orderNumber = self.ordersNumber;
        zhiFuVC.payMoney = [NSString stringWithFormat:@"￥%.2f",[self.orderDic[@"orderTotalprice"] floatValue]];
        zhiFuVC.payType = self.orderDic[@"ordersZffs"];
        [self.navigationController pushViewController:zhiFuVC animated:YES];
    }
}
#pragma mark - 取消订单
- (void)quXiaoOrder:(UIButton *)btn
{
    WeakSelf
    UIAlertController *alertController = [UIAlertController initWithMessage:@"是否取消订单？" bolck:^(void) {
        NSString *code = [NSString stringWithFormat:@"%@%@",safeCode,[GetTimestamp getNowTimeTimestamp]];
        [MBProgressHUD showMessage:nil toView:weakSelf.view];
        [TFNetworking getWithURLString:[NSString stringWithFormat:@"%@/api/json/member/order.ashx?action=orderdelete&companyid=%@&code=%@&timestamp=%@&ordersNumber=%@",kServerURL,companyId,[MD5Encrypt  MD5ForLower32Bate:code],[GetTimestamp getNowTimeTimestamp],self.orderDic[@"ordersNumber"]] parameters:nil success:^(id responseObject) {
            [MBProgressHUD hideHUDForView:weakSelf.view];
            if ([responseObject[@"status"] intValue] == 1) {
                
                // 发送通知
                [[NSNotificationCenter defaultCenter] postNotificationName:@"cancelOrder" object:@"" userInfo:nil];
                [self.navigationController popViewControllerAnimated:YES];
            }
            
        } failure:^(NSError *error) {
            [TFHUD addRemindHUD:weakSelf.view message:@"网络不给力..."];
        }];
    } cancelBolck:^(void) {
        
    }];
    [self presentViewController:alertController animated:YES completion:nil];
}
#pragma mark - 确认收货
- (void)queRenShouHuo
{
    WeakSelf
    UIAlertController *alertController = [UIAlertController initWithMessage:@"是否确认收货？" bolck:^(void) {
        NSString *code = [NSString stringWithFormat:@"%@%@",safeCode,[GetTimestamp getNowTimeTimestamp]];
        [MBProgressHUD showMessage:nil toView:weakSelf.view];
        [TFNetworking getWithURLString:[NSString stringWithFormat:@"%@/api/json/member/order.ashx?action=ordershouhuo&companyid=%@&code=%@&timestamp=%@&ordersNumber=%@",kServerURL,companyId,[MD5Encrypt  MD5ForLower32Bate:code],[GetTimestamp getNowTimeTimestamp],self.orderDic[@"ordersNumber"]] parameters:nil success:^(id responseObject) {
            [MBProgressHUD hideHUDForView:weakSelf.view];
            if ([responseObject[@"status"] intValue] == 1) {
                // 发送通知
                [[NSNotificationCenter defaultCenter] postNotificationName:@"confirmOrder" object:@"" userInfo:nil];
                [self.navigationController popViewControllerAnimated:YES];
            }
            
        } failure:^(NSError *error) {
            [TFHUD addRemindHUD:weakSelf.view message:@"网络不给力..."];
        }];
    } cancelBolck:^(void) {
        
    }];
    [self presentViewController:alertController animated:YES completion:nil];
}
#pragma mark - 售后
- (void)shouHouAction:(UIButton *)btn
{
    // 判断是否售后
    if (self.orderDic) {
        NSString *code = [NSString stringWithFormat:@"%@%@",safeCode,[GetTimestamp getNowTimeTimestamp]];
        NSArray *array = self.orderDic[@"OrderGoodsList"];
        NSDictionary *dic = array[0];
        [MBProgressHUD showMessage:nil toView:self.view];
        [TFNetworking getWithURLString:[NSString stringWithFormat:@"%@/api/json/member/aftersale.ashx?action=info&companyid=%@&code=%@&timestamp=%@&cartid=%@&commodityid=%@&from=mobile",kServerURL,companyId,[MD5Encrypt  MD5ForLower32Bate:code],[GetTimestamp getNowTimeTimestamp],dic[@"CartId"],dic[@"commodityId"]] parameters:nil success:^(id responseObject) {
            [MBProgressHUD hideHUDForView:self.view];
            
            if ([responseObject[@"status"] intValue] == 1) {
                if ([responseObject[@"repairsCheck"] intValue] == 0) {
                    // 未提交过售后
                    ShouHouViewController *shouHouVC = [[ShouHouViewController alloc] init];
                    shouHouVC.orderDic = self.orderDic;
                    shouHouVC.goodsIndex = btn.tag;
                    [self.navigationController pushViewController:shouHouVC animated:YES];
                } else if ([responseObject[@"repairsCheck"] intValue] == 1) {
                    // 提交过售后
                    TuiKuanDetailViewController *tuiKuanDetailVC = [[TuiKuanDetailViewController alloc] init];
                    tuiKuanDetailVC.cartid = dic[@"CartId"];
                    tuiKuanDetailVC.commodityid = dic[@"commodityId"];
                    tuiKuanDetailVC.orderId = self.orderDic[@"ordersNumber"];
                    [self.navigationController pushViewController:tuiKuanDetailVC animated:YES];
                }
            } else {
                [TFHUD addRemindHUD:self.view message:responseObject[@"returnMsg"]];
            }
            
        } failure:^(NSError *error) {
            [TFHUD addRemindHUD:self.view message:@"网络不给力..."];
            
        }];
    }
}
#pragma mark - 评价
- (void)pingJiaAction:(UIButton *)btn
{
    // 判断是否评价
    if (self.orderDic) {
        NSString *code = [NSString stringWithFormat:@"%@%@",safeCode,[GetTimestamp getNowTimeTimestamp]];
        NSArray *array = self.orderDic[@"OrderGoodsList"];
        NSDictionary *dic = array[0];
        [MBProgressHUD showMessage:nil toView:self.view];
        [TFNetworking getWithURLString:[NSString stringWithFormat:@"%@/api/json/member/order.ashx?action=ordergoodcomment&companyid=%@&code=%@&timestamp=%@&cartid=%@&from=mobile",kServerURL,companyId,[MD5Encrypt  MD5ForLower32Bate:code],[GetTimestamp getNowTimeTimestamp],dic[@"CartId"]] parameters:nil success:^(id responseObject) {
            [MBProgressHUD hideHUDForView:self.view];
            
            if ([responseObject[@"status"] intValue] == 1) {
                if ([responseObject[@"cid"] intValue] == 0) {
                    // 未提交过评价
                    NSArray *array = self.orderDic[@"OrderGoodsList"];
                    NSDictionary *dic = array[btn.tag];
                    PingJiaViewController *pingJiaVC = [[PingJiaViewController alloc] init];
                    pingJiaVC.goodsDic = [NSDictionary dictionaryWithDictionary:dic];
                    [self.navigationController pushViewController:pingJiaVC animated:YES];
                } else if ([responseObject[@"cid"] intValue] > 0) {
                    // 提交过评价
                    PingJiaDetailViewController *pingJiaDetailVC = [[PingJiaDetailViewController alloc] init];
                    pingJiaDetailVC.CartId = dic[@"CartId"];
                    [self.navigationController pushViewController:pingJiaDetailVC animated:YES];
                }
            } else {
                //                [TFHUD addRemindHUD:self.view message:responseObject[@"returnMsg"]];
                // 未提交过评价
                NSArray *array = self.orderDic[@"OrderGoodsList"];
                NSDictionary *dic = array[btn.tag];
                PingJiaViewController *pingJiaVC = [[PingJiaViewController alloc] init];
                pingJiaVC.goodsDic = [NSDictionary dictionaryWithDictionary:dic];
                [self.navigationController pushViewController:pingJiaVC animated:YES];
            }
            
        } failure:^(NSError *error) {
            [TFHUD addRemindHUD:self.view message:@"网络不给力..."];
            
        }];
    }
    
}
- (UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, SafeAreaTopHeight, kScreenWidth, kScreenHeight-SafeAreaTopHeight) style:(UITableViewStyleGrouped)];
        _tableView.backgroundColor = tableViewBgColor;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.separatorStyle = NO;
        _tableView.estimatedRowHeight = 0;
        _tableView.estimatedSectionFooterHeight = 0;
        _tableView.estimatedSectionHeaderHeight = 0;
    }
    return _tableView;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
